/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
 *
 * @author alumno
 */
@Entity
@Table(name = "PRECIO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Precio.findAll", query = "SELECT p FROM Precio p"),
    @NamedQuery(name = "Precio.findByModCod", query = "SELECT p FROM Precio p WHERE p.precioPK.modCod = :modCod"),
    @NamedQuery(name = "Precio.findByAlutCod", query = "SELECT p FROM Precio p WHERE p.precioPK.alutCod = :alutCod"),
    @NamedQuery(name = "Precio.findByPrecCod", query = "SELECT p FROM Precio p WHERE p.precioPK.precCod = :precCod"),
    @NamedQuery(name = "Precio.findByPrecMont", query = "SELECT p FROM Precio p WHERE p.precMont = :precMont")})
public class Precio implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PrecioPK precioPK;
    @Basic(optional = false)
    @Column(name = "PREC_MONT")
    private double precMont;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "precio", fetch = FetchType.LAZY)
    private List<PrecioHistorial> precioHistorialList;
    @JoinColumn(name = "MOD_COD", referencedColumnName = "MOD_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Modulo modulo;
    @JoinColumn(name = "ALUT_COD", referencedColumnName = "ALUT_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private AlumnoTipo alumnoTipo;

    public Precio() {
    }

    public Precio(PrecioPK precioPK) {
        this.precioPK = precioPK;
    }

    public Precio(PrecioPK precioPK, double precMont) {
        this.precioPK = precioPK;
        this.precMont = precMont;
    }

    public Precio(int modCod, int alutCod, int precCod) {
        this.precioPK = new PrecioPK(modCod, alutCod, precCod);
    }

    public PrecioPK getPrecioPK() {
        return precioPK;
    }

    public void setPrecioPK(PrecioPK precioPK) {
        this.precioPK = precioPK;
    }

    public double getPrecMont() {
        return precMont;
    }

    public void setPrecMont(double precMont) {
        this.precMont = precMont;
    }

    @XmlTransient
    public List<PrecioHistorial> getPrecioHistorialList() {
        return precioHistorialList;
    }

    public void setPrecioHistorialList(List<PrecioHistorial> precioHistorialList) {
        this.precioHistorialList = precioHistorialList;
    }

    public Modulo getModulo() {
        return modulo;
    }

    public void setModulo(Modulo modulo) {
        this.modulo = modulo;
    }

    public AlumnoTipo getAlumnoTipo() {
        return alumnoTipo;
    }

    public void setAlumnoTipo(AlumnoTipo alumnoTipo) {
        this.alumnoTipo = alumnoTipo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (precioPK != null ? precioPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Precio)) {
            return false;
        }
        Precio other = (Precio) object;
        if ((this.precioPK == null && other.precioPK != null) || (this.precioPK != null && !this.precioPK.equals(other.precioPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Precio[ precioPK=" + precioPK + " ]";
    }
    
}
